package org.core.tliaswebmanagement.config;

import org.core.tliaswebmanagement.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

//    @Autowired
//    private DemoInterceptor demoInterceptor;
    @Autowired
    private TokenInterceptor tokenInterceptor;

    /**
     * /*一级路径拦截，能匹配/dept,不能匹配/dept/1
     * /** 任意级路径拦截
     * /dept/* dept下的一级路径拦截,能匹配/dept/1,不能匹配/dept/1/2
     * /dept/** dept下任意级路径拦截
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("/**")// 拦截所有请求
                .excludePathPatterns("/login");// 排除login请求
    }
}
